#!/bin/bash 
i=1
fifo=$(mktemp -u)
mkfifo "$fifo"

# 启动读取进程
cat "$fifo" &

while (( $i <= 30 )); do
    echo $i >> "$fifo"
    i=$(( $i +1 ))
done

wait
rm "$fifo"
